// eslint-disable-next-line max-classes-per-file
import { PlatformCard } from '@/const';
import { JsonProperty, Serializable } from '@/plugins/reflect-metadata';

import CardItem from './CardItem';

@Serializable()
export class CardQuery {
  @JsonProperty('popular')
    popular: boolean = true;

  @JsonProperty('cardProductName')
    cardProductName: string = '';

  @JsonProperty('cardProductType')
    cardProductType: string = '';

  @JsonProperty('platformType')
    platformType: string = PlatformCard.xunka;

  get search() {
    return {
      cardProductName: this.cardProductName,
    };
  }

  get filter() {
    return {
      cardProductType: this.cardProductType,
      platformType: this.platformType,
    };
  }

  get list() {
    return {
      popular: this.popular,
      platformType: this.platformType,
    };
  }

  // eslint-disable-next-line class-methods-use-this
  get all() {
    return {
      platformType: this.platformType,
    };
  }
}

@Serializable()
export default class CardList {
  @JsonProperty({ name: 'data', type: CardItem })
    items: CardItem[] = [];

  get total() {
    return this.items.length;
  }
}
